<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="s"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ page session="false"%>
<%@ page pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <title>attr list</title>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
        
        <link href="<c:url value="/resources/css/style.css" />" rel="stylesheet" type="text/css" />
        <link href="<c:url value="/resources/jqueryui/1.8/themes/ui-lightness/jquery-ui-1.8.16.custom.css" />" rel="stylesheet" type="text/css" />

        <script src="<c:url value="/resources/jquery/jquery.js" />"></script>
        <script src="<c:url value="/resources/jqueryui/1.8/jquery-ui-1.8.16.custom.min.js" />"></script>
        <script src="<c:url value="/resources/jqueryui/1.8/jquery.ui.datepicker-zh-CN.js" />"></script>
        <script src="<c:url value="/resources/jquery/plugin/cookie/jquery.cookie.js" />"></script>
        <script src="<c:url value="/resources/scripts/html5.js" />"></script>
        
        <script src="<c:url value="/categoryUtil" />"></script>
        <style>
        </style>
    </head>
    <body>
        <table class="table-list-style">
            <caption style="text-align:left">
            </caption>
            <thead align="left">
                <tr>
                    <th align="left">属性名称</th>
                    <th align="left">添加日期</th>
                    <th align="left">删除</th>
                </tr>
            </thead>
            <tbody>
            <c:forEach var="attr" items="${category.categoryAttrs}">
                <tr>
                    <td>${attr.attrName}</td>
                    <td>2012-01-01</td>
                    <td><a href="javascript:deleteAttr(${attr.id});">Delete</a></td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
        <div class="actionItems">
        <form action="<c:url value="/admin/category/addAttr" />" method="post">
            <input type="hidden" name="categoryId" value="${category.id}" />
            <span class="fwb f2">添加新属性: </span>
            <input type="text" name="newAttr" id="newAttr" />
            <input type="submit" value="Add" id="btnAddNewAttr" />
        </form>
        </div>
        <div class="actionItems">
            <a href="javascript: gotoCategoryList();" class="button" style="font-size: 1.2em;">返回分类列表</a>
        </div>
    </body>
</html>

<script>

var id = '${category.id}'; 
var attrAddUrl = '<c:url value="/admin/category/addAttr?" />';
var attrDelUrl = '<c:url value="/admin/category/deleteAttr?id=" />';
var categoryListUrl = '<c:url value="/admin/category/list?id=" />';

function deleteAttr(id){
    if(confirm("Are you sure to delete this attr?")){
        document.location.href = attrDelUrl + id;
    }
}

function gotoCategoryList(){
    var pid = id.substring(0, id.length-3);
    document.location.href = categoryListUrl + pid;
}

$(document).ready(function(){
    $('input:submit, .button').button();
});
</script>
